package cn.edu.cqyz.wisdom.controller;

import cn.edu.cqyz.wisdom.entity.R;
import cn.edu.cqyz.wisdom.entity.SessionQa;
import cn.edu.cqyz.wisdom.service.AiKimiService;
import cn.edu.cqyz.wisdom.service.ISessionQaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 会话问题表 前端控制器
 * </p>
 *
 * @author CDHong.it
 * @since 2024-12-18
 */
@RestController
@RequestMapping("/session-qa")
public class SessionQaController {

    @Autowired
    public AiKimiService service;

    @Autowired
    public ISessionQaService iSession;

    /**
     * KIMI 问答
     * */
    @GetMapping("/kimi")
    public String kimiQa(@RequestParam String content){
        try {
            return service.sendRequest(content);
        } catch (Exception e) {
            return "网络异常，重新发送!";
        }
    }

    /**
     * 加入问题/回答
     * */
    @PostMapping("/installSessionQa")
    public R installSessionQa(@RequestBody SessionQa sessionQa){
        System.out.println(sessionQa.getSessionId()+"a"+sessionQa.getProblemContent());
        return iSession.installSessionQa(sessionQa);
    }

    /**
     * 获取问题
     * */
    @GetMapping("/findAllSessionQa")
    public List<SessionQa> findAllSessionQa(@RequestParam Integer sessionId){
        return iSession.findAllSessionQa(sessionId);
    }



}
